/* hello.c */
#include <linux/init.h>
#include <linux/stat.h>
#include <linux/moduleparam.h>
#include <linux/module.h>
#include <linux/kernel.h>
#define AUTH "Anndse <wanghuisf1985@163.com>"
#define DESC "A sample drive"

static short int myshort=24;
static int myint=420;
static long int mylongint=99999;
static char* mystring="dog";

module_param(myshort, short, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP);
MODULE_PARM_DESC(myshort,"A short integer");
module_param(myint, int, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP);
MODULE_PARM_DESC(myint,"An integer");
module_param(mylongint, long, S_IWUSR);
MODULE_PARM_DESC(mylongint,"A long integer");
module_param(mystring, charp, 0000);
MODULE_PARM_DESC(mystring,"A character string");

static int __init hello_init(void)
{
    printk(KERN_ALERT "Hello, linux kernel module\n");
    printk(KERN_ALERT "myshort is a short integer: %hd\n", myshort);
    printk(KERN_ALERT "myint is a integer: %d\n", myint);
    printk(KERN_ALERT "mylongint is a long integer: %ld\n", mylongint);
    printk(KERN_ALERT "mystring is a string: %s\n", mystring);
    return 0;
}
static void __exit hello_exit(void)
{
    printk(KERN_ALERT "Goodbye, I've created a linux kernel module sucessfully\n");
}
module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL"); 

MODULE_AUTHOR(AUTH);
MODULE_DESCRIPTION(DESC);
MODULE_SUPPORTED_DEVICE("mydevice");

